home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Deutsche Edition 1
/
Deutsche Edition 1.iso
/
amok
/
amok_lha
/
amok40.lha
/
Environment
/
MPCompile.Mod
< prev
next >
Wrap
Text File
|
1993-08-15
|
12KB
|
384 lines
MODULE MPCompile;
(* ********************************************************************** *)
(* Compilieren mit der Maus für beliebige Programmierumgebungen *)
(* MPCompile V3.3 --- © 1990 by M.Peuckert *)
(* ********************************************************************** *)
(*---------------------------------------------------------------------------
:Program. MPCompile
:Version. 3.3
:Contants. Compiling, linking, debugging, etc.
:History. V2.0, Markus Peuckert, Simple
:History. V3.0, Markus Peuckert, slightly improved version, Mar-89
:History. V3.3, Markus Peuckert, Mar-90
:Author. Markus Peuckert
:Address. Schützenstr. 50, D-3550 Marburg, West-Germany,
:Copyright. ShareWare
:Language. Modula-2
:Translator. M2Amiga V3.3d
---------------------------------------------------------------------------*)
FROM SYSTEM IMPORT ADR,ADDRESS;
FROM Arts IMPORT Assert;
FROM Exec IMPORT WaitPort, GetMsg, ReplyMsg;
FROM Intuition IMPORT GadgetPtr, IntuiMessagePtr, IDCMPFlags, IDCMPFlagSet,
CloseWindow, WindowFlags, WindowFlagSet, ScreenFlags,
ScreenFlagSet, ActivationFlags, ActivationFlagSet,
WindowPtr, SetWindowTitles, RefreshGadgets,
ActivateGadget, RemoveGList, AddGList, SizeWindow,
MoveWindow, WindowToFront, WindowToBack;
FROM Graphics IMPORT SetRast;
FROM Dos IMPORT Execute, Lock, UnLock, sharedLock, FileLockPtr;
FROM FileSystem IMPORT File;
FROM Strings IMPORT Occurs, Insert, Delete, Length, Copy, first, last;
IMPORT Str;
FROM DosSupport IMPORT OpenCon, CloseCon, CD, WriteS, WriteLn, SetPenColor;
FROM IntuiSup IMPORT CreateWindow, IDCMPOn, IDCMPOff, ActivWindow;
FROM MPGad IMPORT MaxChar, DrawText, BufStrTyp, MakeGad,
compgad, linkgad, debuggad,rungad, exgad, edgad,
popgad, loadgad, savegad, compilgad, linkergad, makegad,
loadergad, prggad, editgad, CompilBuf, LinkerBuf,
LoaderBuf, PrgBuf, EditBuf, CompGad, LoadGad, PrgGad;
FROM MPWin IMPORT WinLEFT, WinTOP, WinHEIGHT, WinWIDTH, DWidth, DHeight,
winTitle, win, win2, ConPtr, rp, rp2, fh;
FROM MPDat IMPORT OpenConfig, CloseConfig, GetConfigParams,
SetConfigParams;
VAR Datei : File;
PrgPath, FileName,
CompExt, LinkExt,
CompilHlp, LinkerHlp : BufStrTyp;
ConTit : ARRAY [0..79] OF CHAR;
WinLeftMax, WinTopMax,
WinLeftMin, WinTopMin,
ConLeft, ConTop,
ConWidth, ConHeight,
gadPos : INTEGER;
maketog : BOOLEAN;
(* Liest s:Compi.config aus, wenn besteht, sonst wird neu eingerichtet *)
PROCEDURE LoadConfig;
BEGIN
IF NOT maketog THEN
OpenConfig (Datei, "s:Compi.config", FALSE)
ELSIF maketog THEN
OpenConfig (Datei, "s:Compi2.config", FALSE)
END;
GetConfigParams (Datei, CompilBuf);
GetConfigParams (Datei, LinkerBuf);
GetConfigParams (Datei, LoaderBuf);
GetConfigParams (Datei, EditBuf);
CloseConfig (Datei);
RefreshGadgets (ADR(LoadGad), win2, NIL)
END LoadConfig;
(* Speichert Angaben des Eingabefensters in s:Compi.config *)
PROCEDURE SaveConfig;
BEGIN
IF NOT maketog THEN
OpenConfig (Datei, "s:Compi.config", TRUE)
ELSIF maketog THEN
OpenConfig (Datei, "s:Compi2.config", TRUE)
END;
SetConfigParams (Datei, CompilBuf);
SetConfigParams (Datei, LinkerBuf);
SetConfigParams (Datei, LoaderBuf);
SetConfigParams (Datei, EditBuf);
CloseConfig (Datei);
END SaveConfig;
(* Ermittelt letztes Vorkommen von token(=CHAR) in Str *)
PROCEDURE LastPos (Str : ARRAY OF CHAR; token : CHAR; start : INTEGER) : INTEGER;
VAR i, len : INTEGER;
BEGIN
len := Length (Str);
FOR i:=len TO start BY -1 DO
IF (Str[i] = token) THEN
RETURN i
END
END;
RETURN -1
END LastPos;
(* Holt Laufwerksbezeichnung und Dateiname aus Eingabestring *)
PROCEDURE Extract (File : ARRAY OF CHAR; VAR dir, prefix : ARRAY OF CHAR);
VAR dirpos, prepos, subpos, len : INTEGER;
ok : BOOLEAN;
BEGIN
len := Length (File);
dirpos := Occurs (File, first, ":", FALSE);
subpos := LastPos (File, "/", first);
prepos := Occurs (File, first, ".", FALSE);
IF (subpos # last) THEN
Copy (dir, File, first, subpos+1);
ok := CD (dir);
IF (prepos # last) THEN Copy (prefix, File, subpos+1, prepos-subpos-1)
ELSE Copy (prefix, File, subpos+1, len-subpos-1) END
ELSIF (subpos = last) THEN
IF (dirpos # last) THEN
Copy (dir, File, first, dirpos+1);
ok := CD (dir);
IF (prepos # last) THEN Copy (prefix, File, dirpos+1, prepos-dirpos-1)
ELSE Copy (prefix, File, dirpos+1, len-dirpos-1) END
ELSIF (dirpos = last) THEN
IF (prepos # last) THEN Copy (prefix, File, first, prepos)
ELSE Copy (prefix, File, first, len) END
END
END;
END Extract;
PROCEDURE GetExt (VAR Prog, Ext : ARRAY OF CHAR);
VAR len, extpos : INTEGER;
BEGIN
len := Length (Prog); extpos := LastPos (Prog, ".", first);
IF (extpos # last) THEN
Copy (Ext, Prog, extpos, len-extpos);
Delete (Prog, extpos, len-extpos)
END
END GetExt;
PROCEDURE ExistFile (Prog : ARRAY OF CHAR) : BOOLEAN;
VAR L : FileLockPtr;
BEGIN
L := NIL;
L := Lock (ADR(Prog), sharedLock);
IF L # NIL THEN
UnLock (L);
RETURN TRUE
ELSE
SetPenColor (fh, 37);
WriteS (fh, "File not available !");
SetPenColor (fh, 0);
WriteLn (fh);
RETURN FALSE
END
END ExistFile;
(* Führt übergebenen String als CLI-Kommando aus *)
PROCEDURE Exec (Prog : ARRAY OF CHAR);
VAR done : INTEGER;
Help : BufStrTyp;
BEGIN
Str.Copy (Help, Prog); Str.Concat (Help, " launched ...");
WriteLn (fh);
SetPenColor (fh, 37);
WriteS (fh, Help);
SetPenColor (fh, 0); WriteLn (fh); WriteLn (fh);
done := Execute (ADR(Prog), NIL, fh)
END Exec;
(* Setzt Filenamen in Compileraufruf anstelle des Platzhalters ein *)
PROCEDURE Prepare (Envir, Prog, Ext : ARRAY OF CHAR; new,loader,tog : BOOLEAN);
VAR pos : INTEGER;
ok : BOOLEAN;
Strn: BufStrTyp;
BEGIN
ok := FALSE;
IDCMPOff (win);
IF (Prog[0]=0C) THEN Prog[0]:=" "; Prog[1]:=0C END;
IF NOT tog THEN
IF loader THEN
Str.Copy (Strn, Prog);
Str.Concat (Strn, Ext);
ok := ExistFile (Strn)
ELSE
Str.Concat (Prog, Ext);
ok := ExistFile (Prog)
END;
ELSE
ok := ExistFile (Prog)
END;
IF ok OR new THEN
pos := Occurs (Envir, first, "#", FALSE);
Delete (Envir, pos, 1);
Insert (Envir, pos, Prog);
Exec (Envir)
END;
IDCMPOn (win, IDCMPFlagSet{closeWindow, gadgetUp, menuPick})
END Prepare;
(* Compilieren, Linken und ausführen *)
PROCEDURE RunAll (Comp, Link, Name : ARRAY OF CHAR);
VAR ok : BOOLEAN;
BEGIN
ok := FALSE;
Prepare (Comp, Name, CompExt, FALSE, FALSE, maketog);
Prepare (Link, Name, LinkExt, FALSE, FALSE, maketog);
IF (Name[0]#0C) THEN
ok := ExistFile (Name);
IF ok THEN Exec (Name) END
END
END RunAll;
(* Setzt Titel des Ausgabefensters *)
PROCEDURE SetConTitle (Merge : ARRAY OF CHAR);
VAR pos : INTEGER;
BEGIN
ConTit := " MPCompile V3.3 --- Output : ";
pos := Occurs (ConTit, first, ":", FALSE);
Insert (ConTit, pos+2, Merge);
Insert (ConTit, Length (ConTit), " ");
SetWindowTitles (ConPtr, ADR(ConTit), NIL)
END SetConTitle;
(* Öffnet Eingabefenster *)
PROCEDURE OpenPop;
VAR ok : BOOLEAN;
BEGIN
win2 := CreateWindow (WinLEFT, WinTOP+WinHEIGHT+1, WinWIDTH, 115,
IDCMPFlagSet{closeWindow, gadgetUp, activeWindow},
WindowFlagSet{windowDrag, windowDepth, windowClose, windowActive,
gimmeZeroZero, activate}, ADR(MakeGad), NIL,
ADR(" MPCompile --- PopWindow Preferences "),
ScreenFlagSet{wbenchScreen});
Assert(win2#NIL,ADR("Kann Fenster nicht öffnen"));
rp2:=win2^.rPort;
DrawText (rp2);
IF (CompilBuf[0] = 0C) THEN
LoadConfig;
CompilHlp := CompilBuf; LinkerHlp := LinkerBuf;
GetExt (CompilHlp, CompExt);
GetExt (LinkerHlp, LinkExt);
END;
ok := ActivateGadget (ADR(PrgGad), win2, NIL)
END OpenPop;
(* Fragt Gadgets des Einganfensters ab *)
PROCEDURE GetPopWindow;
VAR Msg2 : IntuiMessagePtr;
class2 : IDCMPFlagSet;
adr2 : GadgetPtr;
len : INTEGER;
ok : BOOLEAN;
BEGIN
OpenPop;
LOOP
WaitPort (win2^.userPort);
Msg2 := GetMsg (win2^.userPort);
WHILE Msg2#NIL DO
class2 := Msg2^.class; adr2 := Msg2^.iAddress;
ReplyMsg (Msg2);
IF (closeWindow IN class2) THEN EXIT END;
IF (gadgetUp IN class2) THEN
CASE adr2^.gadgetID OF
loadgad : LoadConfig;
CompilHlp := CompilBuf;
LinkerHlp := LinkerBuf;
GetExt (CompilHlp, CompExt);
GetExt (LinkerHlp, LinkExt) |
savegad : SaveConfig |
compilgad : CompilHlp := CompilBuf;
GetExt (CompilHlp, CompExt) |
linkergad : LinkerHlp := LinkerBuf;
GetExt (LinkerHlp, LinkExt) |
prggad : PrgPath[0] := 0C; FileName[0] := 0C;
Extract (PrgBuf, PrgPath, FileName) |
makegad : maketog := NOT maketog |
ELSE
END (* case *)
END; (* if *)
Msg2 := GetMsg (win2^.userPort)
END (* while *)
END; (* loop *)
IF win2#NIL THEN CloseWindow (win2); win2:=NIL END;
SetConTitle (PrgBuf)
END GetPopWindow;
(* Verkleinert das Steuerfenster *)
PROCEDURE MinWin;
VAR dXMov, dYMov : INTEGER;
BEGIN
ConLeft := ConPtr^.leftEdge; ConTop := ConPtr^.topEdge;
ConWidth := ConPtr^.width; ConHeight := ConPtr^.height;
IF fh#NIL THEN CloseCon (fh); fh := NIL END;
gadPos := RemoveGList (win, ADR(CompGad), -1);
SetRast (rp, 0);
SizeWindow (win, -DWidth, -DHeight);
WinLeftMax := win^.leftEdge; WinTopMax := win^.topEdge;
dXMov := WinLeftMin - WinLeftMax; dYMov := WinTopMin - WinTopMax;
MoveWindow (win, dXMov, dYMov);
SetWindowTitles (win, ADR("MPCompile"), NIL);
WindowToBack (win)
END MinWin;
(* Vergrößert das Steuerfenster und CONSOLE-Fenster *)
PROCEDURE MaxWin;
VAR dXMovW, dYMovW, dXMovC, dYMovC,
conwidth, conheight, realPos : INTEGER;
BEGIN
fh := OpenCon ("CON:50/53/500/80/ MPCompile V3.3 --- Output : ");
ConPtr := ActivWindow ();
WindowToFront (ConPtr);
WinLeftMin := win^.leftEdge; WinTopMin := win^.topEdge;
dXMovW := WinLeftMax - WinLeftMin; dYMovW := WinTopMax - WinTopMin;
dXMovC := ConLeft - ConPtr^.leftEdge; dYMovC := ConTop - ConPtr^.topEdge;
conwidth := ConPtr^.width; conheight := ConPtr^.height;
IF (conwidth <= ConWidth) OR (conheight <= ConHeight) THEN
MoveWindow (ConPtr, dXMovC, dYMovC);
SizeWindow (ConPtr, ConWidth - conwidth, ConHeight - conheight)
ELSIF (conwidth > ConWidth) OR (conheight > ConHeight) THEN
SizeWindow (ConPtr, ConWidth - conwidth, ConHeight - conheight);
MoveWindow (ConPtr, dXMovC, dYMovC)
END;
MoveWindow (win, dXMovW, dYMovW);
SizeWindow (win, DWidth, DHeight);
SetConTitle (PrgBuf);
SetWindowTitles (win, ADR(winTitle), NIL);
WindowToFront (win);
realPos := AddGList (win, ADR(CompGad), gadPos, -1, NIL);
RefreshGadgets (ADR(CompGad), win, NIL)
END MaxWin;
(* Holt Messages des Steuerfensters *)
PROCEDURE GetIntuiMsg;
VAR Msg : IntuiMessagePtr;
class : IDCMPFlagSet;
adr : GadgetPtr;
toggle, ok : BOOLEAN;
BEGIN
toggle:=FALSE; ok := FALSE;
LOOP
WaitPort (win^.userPort);
Msg := GetMsg (win^.userPort);
WHILE Msg#NIL DO
class := Msg^.class; adr := Msg^.iAddress;
ReplyMsg (Msg);
IF (closeWindow IN class) THEN EXIT END;
IF (menuPick IN class) THEN
toggle:=NOT toggle;
IF toggle THEN MinWin ELSE MaxWin END
END;
IF (gadgetUp IN class) THEN
CASE adr^.gadgetID OF
compgad : Prepare (CompilHlp, FileName, CompExt,FALSE,FALSE,maketog) |
linkgad : Prepare (LinkerHlp, FileName, LinkExt,FALSE,FALSE,maketog) |
debuggad : Prepare (LoaderBuf, FileName, LinkExt,FALSE,TRUE, maketog) |
rungad : RunAll (CompilHlp, LinkerHlp, FileName) |
exgad : IF (FileName[0]#0C) THEN
ok := ExistFile (FileName);
IF ok THEN Exec (FileName) END
END |
edgad : Prepare (EditBuf, FileName, CompExt, TRUE, FALSE, maketog) |
popgad : GetPopWindow |
ELSE
END (* case *)
END; (* if *)
Msg := GetMsg (win^.userPort)
END (* while *)
END (* loop *)
END GetIntuiMsg;
BEGIN
WinLeftMin := 420; WinTopMin := 15;
CompExt[0] := 0C; LinkExt[0]:= 0C; maketog := FALSE;
GetPopWindow;
GetIntuiMsg;
END MPCompile.Mod